package top.wangjiu.java.jvm.attribute;

import top.wangjiu.java.jvm.AttributeInfo;
import top.wangjiu.java.jvm.constantinfo.ConstantPoolInfo;

/**
 * Deprecated属性表示某个类、字段或方法已经被程序作者定为不再推荐使用，可在代码中使用@Deprecated注解进行设置
 * 是标志类型的布尔属性，只存在有和没有的区别，没有属性值的概念
 * 当然attribute_length的值必须为0x00000000
 */
public class UnrecognizedAttr extends AttributeInfo {

    public final static String NAME = "UnrecognizedAttr";

    private final short attributeNameIndex;   //属性名索引
    private final int attributeLength;       //属性长度
    private final byte[] bytes;
    private final String name;

    public UnrecognizedAttr(short attributeNameIndex,String name, byte[] bytes){
        this.attributeNameIndex = attributeNameIndex;
        this.attributeLength = bytes.length;
        this.bytes = bytes;
        this.name = name;
    }


    @Override
    public short attributeNameIndex() {
        return attributeNameIndex;
    }

    @Override
    public int attributeLength() {
        return attributeLength;
    }

    @Override
    public String toString(ConstantPoolInfo[] poolInfos) {
        return "Unrecognized attribute:" + name;
    }
}
